package operation;

import book.BookList;

import java.util.Scanner;

/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-23
 * Time: 21:22
 */
public class BorrowOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        System.out.println("请输入要借阅的图书名字:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            if (bookList.getPos(i).getName().equals(name)) {
                bookList.getPos(i).setBorrowed(true);
                System.out.println("借阅成功！");
                return;
            }
        }
        System.out.println("没找到 " + name + " 这本书");
    }
}
